package com.wondertek.poms.core.filter.impl;

import com.wondertek.poms.core.filter.BaseRuleFilter;
import com.wondertek.poms.core.filter.RuleFilterChain;
import com.wondertek.poms.dao.po.Content;
import com.wondertek.poms.dao.po.IRulePo;
import com.wondertek.poms.dao.po.PcProductRule;
import com.wondertek.poms.dao.po.PrdInfoRule;

/**
 * @ClassName AuthorizationWayFilter
 * @Description 授权方式过滤器
 * @Author douzi
 * @Date 2019/12/2 16:09
 * @Version 1.0
 */
public class AuthorizationWayFilter extends BaseRuleFilter {
    @Override
    public void doFilter(IRulePo rule, Content c, RuleFilterChain chain) {
        if (rule instanceof PrdInfoRule) {
            PrdInfoRule r = (PrdInfoRule) rule;
            this.baseFilter(r.getPrdRuleId(),
                    r.getAuthorizationWay() == null ? null : r.getAuthorizationWay() + "",
                    c.getAuthorizationWay(),
                    chain,
                    "授权方式-AuthorizationWay");
		} else if (rule instanceof PcProductRule) {
			PcProductRule r = (PcProductRule) rule;
			this.baseFilter(r.getId(), 
					r.getAuthorizationWay() != null ? r.getAuthorizationWay() : "",
					c.getAuthorizationWay(), 
					chain, 
					"授权方式-AuthorizationWay");
		}

        chain.doFilter(rule, c, chain);
    }
}
